//
//  firstTableviewcell.m
//  Protect -A
//
//  Created by 付剑英 on 16/6/16.
//  Copyright © 2016年 付剑英. All rights reserved.
//

#import "firstTableviewcell.h"
#import "MycollectionView.h"
#import "MycollectionViewCell.h"
#import "firstFlowLayout.h"
#import "ModelOfFirst.h"
@interface firstTableviewcell()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic,retain)MycollectionView *collection;
@property (nonatomic,retain)firstFlowLayout *layout;

@end
@implementation firstTableviewcell

//内存管理
-(void)dealloc{
    [self.collection release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
       [self createcollectionview];
    }
    return self;
}
-(void)createcollectionview{
    
    
    self.layout = [[firstFlowLayout alloc]init];
    
    self.collection  = [[MycollectionView alloc]initWithFrame:self.contentView.bounds collectionViewLayout:self.layout];
    self.collection.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.collection];
    self.collection.delegate = self;
    self.collection.dataSource = self;
    
    //注册cell
    
    [self.collection registerClass:[MycollectionViewCell class] forCellWithReuseIdentifier:@"pool"];
    
    [self.collection release];
    
}


-(void)layoutSubviews{
    [super layoutSubviews];
    self.collection.frame =self.contentView.bounds;
}


-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    MycollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"pool" forIndexPath:indexPath];
    
//    ModelOfFirst *mc = _arrSoRt[indexPath.row];
//    cell.model = mc;
    return  cell;
}


-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 8;
}


#pragma mark - ------------ 重写set 更新collectionview内数组数据 ---------------

-(void)setArrSoRt:(NSArray *)arrSoRt{
    if (_arrSoRt !=arrSoRt) {
        [_arrSoRt release];
        _arrSoRt = [arrSoRt retain];
    }
    [_collection reloadData];
    
}




@end
